package com.xzz.finger;

/**
 * @author: hhz
 * @create: 2022-02-15 10:23
 * 剑指 Offer 10- I. 斐波那契数列
 **/
public class Fib {
    public static void main(String[] args) {
        System.out.println(fib(10));
    }
    public static int fib(int n) {
        if(n<2){
            return n;
        }
        int p = 0, q = 0, r = 1;
        for (int i = 2; i <= n; ++i) {
            p = q;
            q = r;
            r = (p + q) % (1000000007);
        }
        return r;
    }
}
